import * as mongoose from 'mongoose';
import { Schema } from 'mongoose';

export const allowEmptyArrayValidator = [
  function (val) {
    return true;
  },
  '',
];

export const fileEntitySchema = new mongoose.Schema(
  {
    t: Number,
    name: { type: String },
    size: { type: Number, default: 0 },
    type: { type: String },
    teamId: { type: Number },
    userId: { type: Number },
    projectId: { type: String },
    route: { type: String },
    path: { type: String },
    tags: {
      type: mongoose.Schema.Types.Mixed,
      required: false,
    },
    w: { type: Number, default: 0 },
    h: { type: Number, default: 0},
    hash: { type: String },
    status: { type: Number, default: 0 },
    poster: { type: String },
    create_time: { type: Number },
    update_time: { type: Number },
    uid: { type: String },
    persistentId: { type: String },
    format_status: { type: Number },
    format_info: {
      type: mongoose.Schema.Types.Mixed,
      required: false,
    },
  },
  { validateBeforeSave: false },
);
